#include <stdio.h>
int main()
{
    int i, j, n, m, k = 1;
    printf("请输入一个整数(2~20):");
    while (scanf("%d %d", &m, &n) != EOF)
    {
        int arr[n][m], b[m][n];
        for (i = 0; i < n; i++)
        {
            for (j = 0; j < m; j++)
            {
                arr[i][j] = k;
                k++;
            }
        }
        int i, j;
        for (i = 0; i < n; i++)
        {
            printf("\n");
            for (j = 0; j < m; j++)
            {
                printf("%3d", arr[i][j]);
                b[j][i] = arr[i][j];
            }
        }
        for (i = 0; i < m; i++)
        {
            printf("\n");
            for (j = 0; j < n; j++)
            {
                printf("%3d ", b[i][j]);
            }
        }
    }
    return 0;
}